const nunjucks = require("nunjucks")
const Koa = require("koa")
const views = require("koa-views")
const static = require("koa-static")
const parser = require("koa-bodyparser")
const models = require("./models");
const controllers = require("./controllers");
const session = require("koa-session");
const app = new Koa()


app.keys = ['2370218992'];
//引用session模块
app.use(session({
    //设置session的过期时间是一个小时
    maxAge:3600000,
},app))

app.use(parser())

app.use(views(__dirname + '/views', {
    //将使用nunjucks模板引擎渲染以html为后缀的文件。
    map: { html: 'nunjucks' }
}));


app.use(controllers());

app.use(static(__dirname + "/layui"));

app.use(static(__dirname + "/static"));



(async () => {
 // await models.sync();
})();



app.listen(3000, () => [
    console.log("服务器运行的地址是:http://127.0.0.1:3000")
])